//
//  MyCenterViewController.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/9/27.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "MyCenterViewController.h"

#import "OptionsPresentViewController.h"
#import "EPAlertViewController.h"
#import "CheckInViewController.h"
#import "MyDocumentViewController.h"
#import "OfflineFileViewController.h"
#import "SettingV2ViewController.h"
#import "MsgListViewController.h"
#import "RecommendViewController.h"
#import "STCoinViewController.h"
#import "MyCollectionViewController.h"
#import "JoinViewController.h"
#import "PersonCertV2ViewController.h"
#import "MechanismCertV2ViewController.h"
#import "PerfessionCertV2ViewController.h"
#import "CompanyCertV2ViewController.h"
#import "MyConsulationListViewController.h"
#import "MySTWXViewController.h"
#import "EasyTakePicViewController.h"
#import "PublicityV2ViewController.h"
#import "SwitchCerterViewController.h"
#import "EditUserInfoV2ViewController.h"
#import "STRenewListViewController.h"

@interface MyCenterViewController ()

/// 模型视图
@property (nonatomic, readonly, strong) MyCenterViewModel* viewModel;

// UI

//IBOutlet
@property (weak, nonatomic) IBOutlet UILabel* accountLabel;
@property (weak, nonatomic) IBOutlet UIView* stTag;
@property (weak, nonatomic) IBOutlet UIImageView* avatarView;
@property (weak, nonatomic) IBOutlet UIButton* infoDetailBtn;
@property (weak, nonatomic) IBOutlet UIButton* checkinBtn;
@property (weak, nonatomic) IBOutlet UILabel* stCoinNumLabel;
@property (weak, nonatomic) IBOutlet UIButton* stCoinBtn;
@property (weak, nonatomic) IBOutlet UILabel* myCollectionNumLabel;
@property (weak, nonatomic) IBOutlet UIButton* myCollectionBtn;
@property (weak, nonatomic) IBOutlet UILabel* myCosulationNumLabel;
@property (weak, nonatomic) IBOutlet UIView* myCosulationTipView;
@property (weak, nonatomic) IBOutlet UIButton* myConsulationBtn;
@property (weak, nonatomic) IBOutlet UIButton* sfrzBtn;
@property (weak, nonatomic) IBOutlet UILabel* sfrzTLabel;
@property (weak, nonatomic) IBOutlet UILabel* sfrzLabel;
@property (weak, nonatomic) IBOutlet UIButton* stsBtn;
@property (weak, nonatomic) IBOutlet UIButton* stwxBtn;
@property (weak, nonatomic) IBOutlet UIButton* stxdBtn;
@property (weak, nonatomic) IBOutlet UIButton* hbjsqBtn;
@property (weak, nonatomic) IBOutlet UIButton* jrrckBtn;
@property (weak, nonatomic) IBOutlet UIButton* sttgBtn;
@property (weak, nonatomic) IBOutlet UIButton* qystqBtn;
@property (weak, nonatomic) IBOutlet UIButton* wdwdBtn;
@property (weak, nonatomic) IBOutlet UIButton* hbgsBtn;
@property (weak, nonatomic) IBOutlet UIButton* tjhyBtn;
@property (weak, nonatomic) IBOutlet UIButton* lxwjBtn;
@property (weak, nonatomic) IBOutlet UIView* jgView;
@property (weak, nonatomic) IBOutlet UIView* extraList1View;
@property (weak, nonatomic) IBOutlet UIView* extraList2View;

@end

@implementation MyCenterViewController
@dynamic viewModel;

- (instancetype)initWithViewModel:(SUViewModel2 *)viewModel
{
    self = [super initWithViewModel:viewModel];
    if (self)
    {
        [self initData];
        [self initLoadForRAC];
        [self initUI];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)initData
{
    
}

- (void)initLoadForRAC
{
    @weakify(self)
    [[self rac_signalForSelector:@selector(viewDidLoad)] subscribeNext:^(id x)
     {
         @strongify(self)
         
     }];
}

- (void)initUI
{
    @weakify(self);
    
    UIView* msgView = [[UIView alloc] initWithFrame:(CGRect) {32.0f + 8.0f, 0, 32.0f, 44.0f}];
    {
        UIButton* msgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        msgBtn.frame = (CGRect) {0, 0, 32.0f, 32.0f};
        [msgBtn setImage:MHImageNamed(@"icon_xiaoxi") forState:UIControlStateNormal];
        [msgBtn.imageView setContentMode:UIViewContentModeCenter];
        [msgBtn addTarget:self action:@selector(onBtnMsg:) forControlEvents:UIControlEventTouchUpInside];
        [msgView addSubview:msgBtn];
        
        UILabel* msgLabel = [[UILabel alloc] initWithFrame:(CGRect) {0, 32.0f, 32.0f, 12.0f}];
        msgLabel.font = [UIFont systemFontOfSize:8.0f];
        msgLabel.textAlignment = NSTextAlignmentCenter;
        msgLabel.text = @"消息";
        [msgView addSubview:msgLabel];
    }
    
    UIView* settingView = [[UIView alloc] initWithFrame:(CGRect) {0, 0, 32.0f, 44.0f}];
    {
        UIButton* settingBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        settingBtn.frame = (CGRect) {0, 0, 32.0f, 32.0f};
        [settingBtn setImage:MHImageNamed(@"icon_shezhi") forState:UIControlStateNormal];
        [settingBtn.imageView setContentMode:UIViewContentModeCenter];
        [settingBtn addTarget:self action:@selector(onBtnSetting:) forControlEvents:UIControlEventTouchUpInside];
        [settingView addSubview:settingBtn];
        
        UILabel* settingLabel = [[UILabel alloc] initWithFrame:(CGRect) {0, 32.0f, 32.0f, 12.0f}];
        settingLabel.font = [UIFont systemFontOfSize:8.0f];
        settingLabel.textAlignment = NSTextAlignmentCenter;
        settingLabel.text = @"设置";
        [settingView addSubview:settingLabel];
    }
    
    UIView* rightView = [[UIView alloc] initWithFrame:(CGRect) {0, 0, 32.0f*2 + 8.0f, 44.0f}];
    [rightView addSubview:settingView];
    [rightView addSubview:msgView];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightView];
    
    self.tabBarItem.title = @"个人中心";
    self.tabBarItem.image = [[UIImage imageNamed:@"tabbar_personal"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.tabBarItem.selectedImage = [[UIImage imageNamed:@"tabbar_personal_selected"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}

- (void)bindViewModel
{
    [super bindViewModel];
    
    @weakify(self)
    
    RACSignal* willAppearSignal = [[self rac_signalForSelector:@selector(viewWillAppear:)] replay];
    RACSignal* didAppearSignal = [[self rac_signalForSelector:@selector(viewDidAppear:)] replay];
    RACSignal* viewDidLayoutSVSignal = [[self rac_signalForSelector:@selector(viewDidLayoutSubviews)] replay];
    [willAppearSignal subscribeNext:^(id x) {
        @strongify(self);
    }];
    
    [didAppearSignal subscribeNext:^(id x) {
        @strongify(self)
        
        // ScrollView 内容 未能在此时才约束
        
        //Request
    }];
    
    [[self rac_signalForSelector:@selector(viewWillDisappear:)] subscribeNext:^(id x)
     {
         @strongify(self)
         
     }];
    
    [[[viewDidLayoutSVSignal take:1] deliverOnMainThread] subscribeNext:^(id x)
     {
         @strongify(self)
         
         //重置 更新 frame
         [self _setupAllView];
     }];
    
#pragma mark -- bindViewModel
    
    UserManagerV2* um = [UserManagerV2 sharedUserManagerV2];
    
    RACSignal* userDetailChangeSignal = [RACObserve(um, userDetailData) doNext:^(id x)
    {
        NSLog(@"UserDetailChange ------- 1");
    }];
    
    [[[RACObserve(um, userData) distinctUntilChanged] filter:^BOOL(id value) {
        
        return value!=nil;
    }] subscribeNext:^(id x)
     {
         @strongify(self)
         
         UserInfoData* curUserData = x;
         
         NSString* strNickName = (curUserData.wxNickName!=nil && [curUserData.wxNickName isNotBlank]) ? curUserData.wxNickName : ((curUserData.nickname!=nil && [curUserData.nickname isNotBlank]) ? curUserData.nickname : @"") ;
         NSString* strHeadImg = (curUserData.wxHeadImg!=nil && [curUserData.wxHeadImg isNotBlank]) ? curUserData.wxHeadImg : ((curUserData.headimg!=nil && [curUserData.headimg isNotBlank]) ? curUserData.headimg : @"") ;
         
         [self.avatarView yy_setImageWithURL:[NSURL URLWithString:strHeadImg] placeholder:MHImageNamed(@"placeholderLogo")];
         
         NSString* strNameLabel = [strNickName isNotBlank] ? strNickName : curUserData.mobile;
         self.accountLabel.text = strNameLabel;
         
         //更新列表
         NSInteger finalIdentify = [curUserData.identify integerValue];
         
         self.extraList1View.hidden = finalIdentify == 4;
         self.extraList2View.hidden = finalIdentify != 4;

         BOOL isShowJGPart = finalIdentify == 2 || finalIdentify == 4;
         for (NSLayoutConstraint* curConstraint in self.jgView.constraints)
         {
             if (curConstraint.firstAttribute == NSLayoutAttributeHeight)
             {
                 curConstraint.constant = isShowJGPart?88.0f:0.0f;
                 
                 break;
             }
         }
     }];
    
    //用户信息按钮
    [[self.infoDetailBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x)
    {
        @strongify(self);
        [self _push2EditUserInfoVC];
    }];
    
    //签到按钮
    [[self.checkinBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        
        @strongify(self);
        [self.viewModel.checkinCmd execute:nil];
    }];
    
    [[self.viewModel.checkinCmd.executionSignals.switchToLatest deliverOnMainThread] subscribeNext:^(id x) {
       
        @strongify(self);
        [self _push2CheckInVC];
    }];
    [[self.viewModel.checkinCmd.errors deliverOnMainThread] subscribeNext:^(NSError* error) {
        
        @strongify(self);
    }];
    
    //生态币
    [[self.stCoinBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        
        @strongify(self);
        [self _presentSTCoinVC];
    }];
    RAC(self.stCoinNumLabel, text) = RACObserve(self.viewModel, coinNum);
    
    //我的收藏
    [[self.myCollectionBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        
        @strongify(self);
        [self _push2MyCollectionVC];
    }];
    RAC(self.myCollectionNumLabel, text) = RACObserve(self.viewModel, collectionNum);
    
    //我的咨询
    [[self.myConsulationBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        
        @strongify(self);
        [self _push2MyConsulationVC];
    }];
    RAC(self.myCosulationNumLabel, text) = RACObserve(self.viewModel, cosultNum);
    
    //身份认证
    RAC(self.sfrzTLabel, text) = [[[userDetailChangeSignal replay] distinctUntilChanged] map:^id(id value)
    {
        UserDetailData* userDetailData = value;
        NSInteger identify = [userDetailData.user.identify integerValue];
        
        NSString* result = @"";
        
        switch (identify) {
            case 1:
                {
                    result = @"身份认证（个人用户）";
                }
                break;
                
            case 2:
            {
                result = @"身份认证（专家用户）";
            }
                break;
                
            case 3:
            {
                result = @"身份认证（企业用户）";
            }
                break;
                
            case 4:
            {
                NSInteger category = [userDetailData.content.category integerValue];
                NSArray* categorys = @[@"监测单位", @"污染治理", @"危废处理", @"环保服务"];
                
                result = HCStrFormat(@"身份认证（%@）", categorys[category - 1]);
            }
                break;
                
            default:
                break;
        }
        
        return result;
    }];
    
    RAC(self.sfrzLabel, text) = [[[userDetailChangeSignal replay] distinctUntilChanged] map:^id(id value)
    {
        UserDetailData* userDetailData = value;
        NSInteger identify = [userDetailData.user.identify integerValue];
        NSInteger status = 0;
        if (identify > 1)
        {
            status = [userDetailData.content.status integerValue];
        }
        else
        {
            status = [userDetailData.user.status integerValue];
        }
        
        NSString* resultTag = @"";
        
        if (identify == 1)
        {
            if (status == 1)
            {
                resultTag = @"未认证";
            }
            else if (status == 2)
            {
                resultTag = @"切换身份";
            }
        }
        else if (identify > 1)
        {
            if (status == 1)
            {
                resultTag = @"审核中";
            }
            else if (status == 2)
            {
                resultTag = @"已认证";
            }
            else if (status == 3)
            {
                resultTag = @"审核未通过，请查看";
            }
        }
        
        return resultTag;
    }];
    RAC(self.sfrzLabel, textColor) = [RACObserve(self.sfrzLabel, text) map:^id(id value)
    {
        UIColor* textColor = UIColorHex(#e0e0e0);
        
        if ([value containsString:@"认证"])
        {
            textColor = UIColorHex(#e0e0e0);
        }
        else if ([value isEqualToString:@"审核中"] || [value isEqualToString:@"切换身份"])
        {
            textColor = UIColorHex(#53bd91);
        }
        else if ([value containsString:@"审核未通过"])
        {
            textColor = UIColorHex(#ec6468);
        }
        
        return textColor;
    }];
    
    [[self.sfrzBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        
        @strongify(self);
        
        //判断当前用户类型以及状态
        UserManagerV2* um = [UserManagerV2 sharedUserManagerV2];
        UserDetailData* userDetailData = um.userDetailData;
        NSInteger identify = [userDetailData.user.identify integerValue];
        NSInteger status = 0;
        if (identify > 1)
        {
            status = [userDetailData.content.status integerValue];
            
            NSArray* strIDs = @[@"专家", @"企业", @"机构"];
            NSString* strID = strIDs[identify - 2];
            
            if (1 == status) //审核中
            {
                NSString* strTip = HCStrFormat(@"您的%@资料正在审核中...", strID);
                [MBProgressHUD mh_showTips:strTip];
            }
            else if (2 == status) // 已审核
            {
                NSString* strTip = HCStrFormat(@"您的%@资料已经审核通过", strID);
                [MBProgressHUD mh_showTips:strTip];
            }
            else if (3 == status) // 审核被拒
            {
                //弹出对话框
                [self _present2AlertVC];
            }
        }
        else
        {
            status = [userDetailData.user.status integerValue];
            
            if (1 == status)
            {
                [self _push2CerterChooser];
            }
            else if (2 == status)
            {
                [self _push2SwitchCerter];
            }
        }
    }];
    
    // 生态树
    [[self.stsBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x)
     {
         @strongify(self);
         [self _push2STSVC];
     }];
    
    // 环保计税器
    [[self.hbjsqBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x)
    {
        @strongify(self);
        [self _push2HBJSQVC];
    }];
    
    // 我的生态行动
    [[self.stxdBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x)
    {
        @strongify(self);
        [self _push2MyEasyTakePicVC];
    }];
    
    // 我的生态文献
    [[self.stwxBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        
        @strongify(self);
        [self _push2MySTWXVC];
    }];
    
    //我的文档
    [[self.wdwdBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        
        @strongify(self);
        [self _push2MyDocumentVC];
    }];
    
    //环保公示
    [[self.hbgsBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        
        @strongify(self);
        [self _push2PublicityVC];
    }];
    
    //推荐好友
    [[self.tjhyBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        
        @strongify(self);
        [self _push2RecommendVC];
    }];
    
    //离线文件
    [[self.lxwjBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        
        @strongify(self);
        [self _push2OfflineFileVC];
    }];
    
    //加入人才库
    [[self.jrrckBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        
        @strongify(self);
        [self _push2JoinVC];
    }];
    
    //生态推广
    [[self.sttgBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        
        @strongify(self);
        [self _push2STTGVC];
    }];
}

#pragma mark - 更新初始化 操作
- (void)_setupAllView
{
    @weakify(self);
    
    UserManagerV2* um = [UserManagerV2 sharedUserManagerV2];
    
    self.avatarView.layer.cornerRadius = self.avatarView.frame.size.width/2.0f;
    self.avatarView.layer.masksToBounds = YES;
//    [self.avatarView yy_setImageWithURL:[NSURL URLWithString:um.userData.icon] placeholder:MHImageNamed(@"placeholderLogo")];
    
    self.myCosulationTipView.layer.cornerRadius = self.myCosulationTipView.frame.size.width/2.0f;
    self.myCosulationTipView.layer.masksToBounds = YES;

//    NSString* strNameLabel = HCStrFormat(@"账号:%@\n昵称:%@", um.userData.userName, um.userData.nickname);
//    self.nameLabel.text = [um.userData.nickname isNotBlank] ? strNameLabel : @"生态云用户";
//
//    self.wdzzLabel.text = HCStrFormat(@"我的生态币：%d", (int)um.userData.seedCount);
}

#pragma mark - Delegate 一些无法用RAC实现
// UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    
}

#pragma mark-代理方法
// 设立实现代理，注意要返回UIModalPresentationNone
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
{
    return UIModalPresentationNone;
}

#pragma mark - 功能
- (void)onBtnMsg:(id)sender
{
    NSLog(@"On Btn Msg !");
    
    [self _push2MsgListVC];
}

- (void)onBtnSetting:(id)sender
{
    NSLog(@"On Btn Setting !");
    
    [self _push2SettingVC];
}

#pragma mark - 跳转
- (void)_present2AlertVC
{
    @weakify(self);
    
    UserManagerV2* um = [UserManagerV2 sharedUserManagerV2];
    UserDetailData* userDetailData = um.userDetailData;
    NSString* strContent = userDetailData.content.remark;
    
    EPAlertViewModel* vm = [[EPAlertViewModel alloc] initWithParams:@{}];
    vm.strTitle = @"未通审核原因";
    vm.strContent = strContent;
    [vm.confirmCmd.executionSignals.switchToLatest subscribeNext:^(id x)
    {
        @strongify(self);
        
        NSInteger identity = [userDetailData.user.identify integerValue];
        
        NSString* strCertName = @"";
        if (identity == 2)
        {
            strCertName = @"专家认证";
        }
        else if (identity == 3)
        {
            strCertName = @"企业认证";
        }
        else if (identity == 4)
        {
            strCertName = @"机构认证";
        }
        
        [self _push2IDCertVC:strCertName isReload:YES];
    }];
    EPAlertViewController* vc = [[EPAlertViewController alloc] initWithViewModel:vm];
    vc.view.backgroundColor = [UIColor clearColor];
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
    {
        vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    }
    else
    {
        vc.modalPresentationStyle = UIModalPresentationCurrentContext;
    }
    [self presentViewController:vc animated:YES completion:^
     {
         vc.view.backgroundColor = UIColorHex(#0000000f);
     }];
}

- (void)_push2CerterChooser
{
    PersonCertV2ViewModel* vm = [[PersonCertV2ViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"个人认证"}];
    PersonCertV2ViewController* vc = [[PersonCertV2ViewController alloc] initWithViewModel:vm];
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)_push2SwitchCerter
{
    @weakify(self);
    SwitchCerterViewModel* vm = [[SwitchCerterViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"身份切换"}];
    vm.chooseIndex = 0;
    [[vm.chooseCmd.executionSignals.switchToLatest delay:0.5f] subscribeNext:^(id x)
    {
        @strongify(self);
        
        NSInteger chooseIndex = [x integerValue];
        chooseIndex ++;
        
        NSString* strCertName = @"";
        if (chooseIndex == 2)
        {
            strCertName = @"专家认证";
        }
        else if (chooseIndex == 3)
        {
            strCertName = @"企业认证";
        }
        else if (chooseIndex == 4)
        {
            strCertName = @"机构认证";
        }
        
        [self _push2IDCertVC:strCertName isReload:NO];
    }];
    SwitchCerterViewController* vc = [[SwitchCerterViewController alloc] initWithViewModel:vm];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)_push2EditUserInfoVC
{
    UserManagerV2* um = [UserManagerV2 sharedUserManagerV2];
    UserDetailData* userDetailData = um.userDetailData;
    NSInteger identify = [userDetailData.user.identify integerValue];
    NSInteger status = 0;
    NSInteger finalIdentify = 1;
    if (identify > 1)
    {
        status = [userDetailData.content.status integerValue];
        
        if (2 == status)
        {
            finalIdentify = identify;
        }
    }
    else
    {
        status = [userDetailData.user.status integerValue];
    }
    
    EditUserInfoV2ViewModel* vm = [[EditUserInfoV2ViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"修改资料"}];
    vm.type = identify - 1;
    EditUserInfoV2ViewController* vc = [[EditUserInfoV2ViewController alloc] initWithViewModel:vm];
    
    [self.navigationController pushViewController:vc animated:YES];
}

//- (void)_presentSFRZChooser
//{
//    UserManagerV2* um = [UserManagerV2 sharedUserManagerV2];
//    NSInteger identify = [um.userData.identify integerValue];
//
//    NSMutableArray* canChooseTypes = [NSMutableArray array];
//    NSArray* types = @[@"个人认证", @"专家认证", @"机构认证", @"企业认证"];
//
//    switch (identify)
//    {
//        case 0:
//        {
//            [canChooseTypes addObject:@"个人认证"];
//            [canChooseTypes addObject:@"专家认证"];
//            [canChooseTypes addObject:@"机构认证"];
//            [canChooseTypes addObject:@"企业认证"];
//        }
//            break;
//
//        case 1:
//        {
//            [canChooseTypes addObject:@"专家认证"];
//            [canChooseTypes addObject:@"机构认证"];
//            [canChooseTypes addObject:@"企业认证"];
//        }
//            break;
//
//        case 2:
//        {
//            [canChooseTypes addObject:@"机构认证"];
//            [canChooseTypes addObject:@"企业认证"];
//        }
//            break;
//
//        default:
//            break;
//    }
//
//    if (canChooseTypes.count == 0)
//    {
//        [MBProgressHUD mh_showTips:@"已完成认证"];
//
//        return;
//    }
//
//    OptionsPresentViewController* vc = nil;
//
//    @weakify(self);
//    // 测试更多弹出
//    OptionsPresentViewModel* vm = [[OptionsPresentViewModel alloc] initWithParams:@{}];
//    vm.titles = canChooseTypes;
//    vm.topTitle = @"身份认证";
//    vm.selectCmd = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input)
//                    {
//                        @strongify(self);
//
//                        NSIndexPath* indexPath = input;
//
//                        [self _push2IDCertVC:canChooseTypes[indexPath.row]];
//
//                        [[UIViewController getCurrentVC] dismissViewControllerAnimated:vc completion:^{
//
//                        }];
//
//                        return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
//
//                            [subscriber sendCompleted];
//
//                            return nil;
//                        }];
//                    }];
//    vc = [[OptionsPresentViewController alloc] initWithViewModel:vm];
//    vc.view.backgroundColor = [UIColor clearColor];
//    //         vc.modalPresentationStyle = UIModalPresentationOverCurrentContext|UIModalPresentationFullScreen;
//    if ([[[UIDevice currentDevice] systemVersion] floatValue]>=8.0) {
//        vc.modalPresentationStyle=UIModalPresentationOverCurrentContext;
//    }else{
//        vc.modalPresentationStyle=UIModalPresentationCurrentContext;
//    }
//    [[UIViewController getCurrentVC] presentViewController:vc animated:YES completion:^
//     {
//         vc.view.backgroundColor = UIColorHex(#0000000f);
//     }];
//}

- (void)_push2IDCertVC:(NSString*)certName isReload:(BOOL)isReload
{
    if ([certName isEqualToString:@"个人认证"]) //个人认证
    {
        PersonCertV2ViewModel* vm = [[PersonCertV2ViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"个人认证"}];
        PersonCertV2ViewController* vc = [[PersonCertV2ViewController alloc] initWithViewModel:vm];
        
        [self.navigationController pushViewController:vc animated:YES];
    }
    else if ([certName isEqualToString:@"专家认证"]) //专家认证
    {
        PerfessionCertV2ViewModel* vm = [[PerfessionCertV2ViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"专家认证"}];
        vm.isReload = isReload;
        PerfessionCertV2ViewController* vc = [[PerfessionCertV2ViewController alloc] initWithViewModel:vm];
        
        [self.navigationController pushViewController:vc animated:YES];
    }
    else if ([certName isEqualToString:@"机构认证"])  //机构认证
    {
        MechanismCertV2ViewModel* vm = [[MechanismCertV2ViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"机构认证"}];
        vm.isReload = isReload;
        MechanismCertV2ViewController* vc = [[MechanismCertV2ViewController alloc] initWithViewModel:vm];
        
        [self.navigationController pushViewController:vc animated:YES];
    }
    else if ([certName isEqualToString:@"企业认证"]) //企业认证
    {
        CompanyCertV2ViewModel* vm = [[CompanyCertV2ViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"企业认证"}];
        vm.isReload = isReload;
        CompanyCertV2ViewController* vc = [[CompanyCertV2ViewController alloc] initWithViewModel:vm];
        
        [self.navigationController pushViewController:vc animated:YES];
    }
}

- (void)_push2STSVC
{
    [MBProgressHUD mh_showTips:@"生态树功能暂未开放"];
}

- (void)_push2HBJSQVC
{
    WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
    launchMiniProgramReq.userName = @"gh_429a1036e971";  //拉起的小程序的username
    launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //拉起小程序的类型
    [WXApi sendReq:launchMiniProgramReq];
}

- (void)_push2MyDocumentVC
{
    MyDocumentViewModel* vm = [[MyDocumentViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"我的文档"}];
    MyDocumentViewController* vc = [[MyDocumentViewController alloc] initWithViewModel:vm];
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)_push2MyEasyTakePicVC
{
    UserManagerV2* um = [UserManagerV2 sharedUserManagerV2];
    
    EasyTakePicViewModel* vm = [[EasyTakePicViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"我的发布"}];
    vm.isMyself = YES;
    EasyTakePicViewController* vc = [[EasyTakePicViewController alloc] initWithViewModel:vm];
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)_push2MySTWXVC
{
    MySTWXViewModel* vm = [[MySTWXViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"我的生态文献"}];
    MySTWXViewController* vc = [[MySTWXViewController alloc] initWithViewModel:vm];
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)_push2MyConsulationVC
{
    MyConsulationListViewModel* vm = [[MyConsulationListViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"我咨询的问题"}];
    MyConsulationListViewController* vc = [[MyConsulationListViewController alloc] initWithViewModel:vm];
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)_push2CheckInVC
{
    CheckInViewModel* vm = [[CheckInViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"签到"}];
    CheckInViewController* vc = [[CheckInViewController alloc] initWithViewModel:vm];
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)_push2OfflineFileVC
{
    OfflineFileViewModel* vm = [[OfflineFileViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"离线文件"}];
    OfflineFileViewController* vc = [[OfflineFileViewController alloc] initWithViewModel:vm];
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)_push2SettingVC
{
    SettingV2ViewModel* vm = [[SettingV2ViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"设置"}];
    SettingV2ViewController* vc = [[SettingV2ViewController alloc] initWithViewModel:vm];
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)_push2MsgListVC
{
    MsgListViewModel* vm = [[MsgListViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"消息"}];
    MsgListViewController* vc = [[MsgListViewController alloc] initWithViewModel:vm];
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)_push2JoinVC
{
    JoinViewModel* vm = [[JoinViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"加入人才库"}];
    JoinViewController* vc = [[JoinViewController alloc] initWithViewModel:vm];
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)_push2STTGVC
{
    STRenewListViewModel* vm = [[STRenewListViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"生态推广"}];
    STRenewListViewController* vc = [[STRenewListViewController alloc] initWithViewModel:vm];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)_push2RecommendVC
{
    RecommendViewModel* vm = [[RecommendViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"推荐好友"}];
    RecommendViewController* vc = [[RecommendViewController alloc] initWithViewModel:vm];
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)_presentSTCoinVC
{
    STCoinViewModel* vm = [[STCoinViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"生态币"}];
    STCoinViewController* vc = [[STCoinViewController alloc] initWithViewModel:vm];
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)_push2MyCollectionVC
{
    MyCollectionViewModel* vm = [[MyCollectionViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"我的收藏"}];
    MyCollectionViewController* vc = [[MyCollectionViewController alloc] initWithViewModel:vm];
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)_push2PublicityVC
{
    PublicityV2ViewModel* vm = [[PublicityV2ViewModel alloc] initWithParams:@{SUViewModelTitleKey:@"环保公示"}];
    PublicityV2ViewController* vc = [[PublicityV2ViewController alloc] initWithViewModel:vm];
    [self.navigationController pushViewController:vc animated:YES];
}

@end
